import 'package:flutter/src/widgets/framework.dart';
//////import 'package:fluttertoast/fluttertoast.dart';
import 'package:flutter_module/beans/share.dart';
import 'package:flutter_module/commom/check.dart';
import 'package:flutter_module/http/view_model.dart';
import 'package:oktoast/oktoast.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../DemoLocalizations.dart';


shareViewModel shareViewModel1 = new shareViewModel();

class shareViewModel extends ViewModel {
  /*
  * 按时间线获取事件
  * */
  Future<dynamic> getEntityNews(BuildContext context) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    String uuid = sp.getString("uuid");
    if(uuid==null){
     showToast(DemoLocalizations.of(context).LoginFirst);
    }else{
    final Map map = await ShareReqModel().data(uuid);
    List list = new List();
    if (map != null && map.isNotEmpty) {
      final data = map['result'];
      if (listNoEmpty(data)) {
        data.forEach((json) => list.add(Result.fromJson(json)));
      }else{
        showToast(DemoLocalizations.of(context).NoShare);
      }
    }
    return Future.value(list);
    }
  }
}
